import {ref} from "vue";

export function usePagination(defaultSize = 10) {
    const current = ref(1);
    const size = ref(defaultSize);
    const total = ref(0);

    const setCurrent = (newPage) => {
        current.value = newPage;
    };

    const setSize = (newSize) => {
        size.value = newSize;
        // 切换每页数量时重置页码
        current.value = 1;
    };

    const setTotal = (newTotal) => {
        total.value = newTotal;
    };

    return {
        current,
        size,
        total,
        setCurrent,
        setSize,
        setTotal,
    };
}
